using System;
using System.Collections.Generic;

using Dashboard;
using Dashboard.Util;

using Gtk;

using Dashboard.Mint.Tiles;

namespace Dashboard.Sidebar
{
	public class TilePage : ScrolledWindow
	{
		private Dictionary<Tile, TileBox> tiles = new Dictionary <Tile, TileBox> ();

		private VBox vbox = null;

		public TilePage ()
		{
			base.HscrollbarPolicy = PolicyType.Never;
			base.VscrollbarPolicy = PolicyType.Automatic;
			base.ShadowType = ShadowType.None;

			vbox = new VBox (false, 2);

			Viewport viewport = new Viewport ();
			viewport.ShadowType = ShadowType.None;
			viewport.Add (vbox);

			base.Child = viewport;
		}

		public void AddTile (Tile tile)
		{
			TileBox box = new TileBox (tile);
			vbox.PackStart (box, false, false, 0);
			
			vbox.ShowAll ();
		}

		public void RemoveTile (Tile tile)
		{
			if (tiles.ContainsKey (tile)) {
				vbox.Remove (tiles [tile]);
				tiles.Remove (tile);
			}
		}

		public bool ContainsTile (Tile tile)
		{
			return tiles.ContainsKey (tile);
		}
	}
}
